var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var e in i)
              Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]);
          })(i, e);
      };
      return function (i, e) {
        function n() {
          this.constructor = i;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(i, e),
          (i.prototype =
            null === e
              ? Object.create(e)
              : ((n.prototype = e.prototype), new n()));
      };
    })(),
  TrainDetailDialog = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        (i.textfield = null),
        (i.max = 10),
        (i.min = 0),
        (i.step = 1),
        (i.num = 0),
        (i.onLoadTraninSureResultFn = {
          caller: i,
          code: 1207,
          method: function (t) {
            "0" == t.code
              ? (ToastView.toastView(t.data),
                WebSocketService.send({ c: 1205, d: null }),
                WebSocketService.send({ c: 1204, d: { t: 1 } }),
                WebSocketService.send({ c: 1331, d: null }),
                Laya.stage.event("GameMainView", "exp"),
                Laya.stage.event("HomePageView", "exp"),
                i.close())
              : ToastView.toastView(t.msg);
          },
        }),
        i.btn_train_sure.on(Laya.Event.CLICK, i, i.onTrainSureAction),
        i.btn_train_dele.on(Laya.Event.CLICK, i, i.onDidClickItemFn),
        i.btn_train_plus.on(Laya.Event.CLICK, i, i.onDidClickItemFn),
        i.slider_trainDetail.on(Laya.Event.CHANGE, i, i.onSliderTrainChange),
        (i.slider_trainDetail.max = i.max),
        (i.slider_trainDetail.min = 0),
        (i.slider_trainDetail.value = 0),
        WebSocketService.addListener(i.onLoadTraninSureResultFn, !0),
        i.btn_trainDetail_cancle.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickTrainDetailFn
        ),
        i
      );
    }
    return (
      __extends(i, t),
      (i.showTrainDetail = function (t) {
        null == this.trainDetail &&
          ((this.trainDetail = new i()), (this.trainDetail.zOrder = 1e3)),
          this.trainDetail.popup(!0),
          (this.trainDetail.trainObj = t),
          (this.trainDetail.slider_trainDetail.value = 0),
          (this.trainDetail.label_train_title.text = "训练"),
          this.trainDetail.setupHtmlDivUI();
      }),
      (i.prototype.setupHtmlDivUI = function () {
        null == this.textfield &&
          ((this.textfield = new Laya.HTMLDivElement()),
          (this.textfield.width = 200),
          this.textfield.pos(50, 60),
          (this.textfield.style.leading = 6),
          this.addChild(this.textfield));
        var t =
          "<span style='color:#7F4021; font-size:15px; '> " +
          this.trainObj +
          "</span><br/><br/>";
        this.textfield.innerHTML = t;
      }),
      (i.prototype.onDidClickItemFn = function (t) {
        "item0" == t.target.name
          ? ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slider_trainDetail.value = this.num))
          : "item1" == t.target.name &&
            ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slider_trainDetail.value = this.num)),
          (this.label_train_time.text =
            this.slider_trainDetail.value + " 个小时");
      }),
      (i.prototype.onSliderTrainChange = function () {
        (this.num = this.slider_trainDetail.value),
          (this.label_train_time.text =
            this.slider_trainDetail.value + " 个小时");
      }),
      (i.prototype.onTrainSureAction = function () {
        this.num <= 0 || WebSocketService.send({ c: 1207, d: { h: this.num } });
      }),
      (i.prototype.onDidClickTrainDetailFn = function () {
        this.close();
      }),
      (i.close = function () {
        this.trainDetail &&
          (this.trainDetail.textfield, (this.trainDetail = null));
      }),
      i
    );
  })(ui.SubSquareController.TrainDetailDialogUI);
